home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mac Format 1994 October
/
Macformat17.cdr
/
Shareware City
/
Developers
/
shutdown-fx-201-c
/
sfx ƒ
/
sfx control app ƒ
/
sfx code ƒ
/
pixel dissolve.c
< prev
next >
Wrap
Text File
|
1994-07-11
|
3KB
|
122 lines
/**********************************************************************\
File: pixel dissolve.c
Purpose: Graphic effect to copy offscreen grafptr to onscreen window.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program in a file named "GNU General Public License".
If not, write to the Free Software Foundation, 675 Mass Ave,
Cambridge, MA 02139, USA.
\**********************************************************************/
#include "pixel dissolve.h"
#include "timing.h"
#define SUB_HEIGHT 25
#define SUB_WIDTH 25
#define POINT_SIZE 1
#define theWindowHeight (boundsRect.bottom-boundsRect.top)
#define theWindowWidth (boundsRect.right-boundsRect.left)
#define CorrectTime 1
static pascal unsigned long UniformRandomUL(unsigned long *theSeed);
pascal short PixelDissolve(GrafPtr sourceGrafPtr, GrafPtr destGrafPtr, Rect boundsRect)
{
register long row,col,r;
unsigned long w, h;
Point *ptptr;
unsigned long iter, save_iter;
Rect temp;
short i,j;
register long theValue;
unsigned long theSeed;
w=theWindowWidth;
h=theWindowHeight;
save_iter=iter=SUB_HEIGHT*SUB_WIDTH/(POINT_SIZE*POINT_SIZE);
ptptr=(Point*)NewPtr(sizeof(Point)*iter);
if (ptptr==0L)
return -1;
iter=0;
for (i=0; i<SUB_HEIGHT; i+=POINT_SIZE)
{
theValue=i;
theValue<<=16;
for (j=0; j<SUB_WIDTH; j+=POINT_SIZE)
{
((long*)ptptr)[iter++]=theValue;
theValue+=POINT_SIZE;
}
}
GetDateTime(&theSeed);
for (iter=1; iter<save_iter; iter++)
{
r=UniformRandomUL(&theSeed)%iter;
theValue=((long*)ptptr)[r];
((long*)ptptr)[r]=((long*)ptptr)[iter];
((long*)ptptr)[iter]=theValue;
}
for (iter=0; iter<save_iter; iter++)
{
StartTiming();
temp.left=ptptr[iter].h;
temp.top=ptptr[iter].v;
temp.right=temp.left+POINT_SIZE;
temp.bottom=temp.top+POINT_SIZE;
for (row=0; row<h; row+=SUB_HEIGHT)
{
for (col=0; col<w; col+=SUB_WIDTH)
{
CopyBits(&(sourceGrafPtr->portBits), &(destGrafPtr->portBits),
&temp, &temp, 0, 0L);
temp.left+=SUB_WIDTH;
temp.right+=SUB_WIDTH;
}
temp.left-=col;
temp.right-=col;
temp.top+=SUB_HEIGHT;
temp.bottom+=SUB_HEIGHT;
}
TimeCorrection(CorrectTime);
}
DisposePtr(ptptr);
return 0;
}
#define M 1664525
#define C 1
#define LOW(X) (X&0xFFFF)
#define HIGH(X) ((X>>16)&0xFFFF)
pascal unsigned long UniformRandomUL(unsigned long *seed)
{
unsigned long lo, hi;
lo=LOW(LOW(*seed)*LOW(M)+C);
hi=LOW(HIGH(*seed)*LOW(M))+LOW(HIGH(M)*LOW(*seed))+
HIGH(LOW(*seed)*LOW(M)+C);
*seed=((hi<<16)|lo);
return *seed;
}